package com.wjr.braveheart.ui.mvp;

import android.content.Context;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.wjr.braveheart.ui.fragment.AppFragment;
import com.wjr.braveheart.ui.mvp.proxy.FragmentMvpProxy;
import com.wjr.braveheart.ui.mvp.proxy.FragmentMvpProxyImpl;

public abstract class MvpBaseFragment extends AppFragment implements IMvpBaseView {

    private FragmentMvpProxy mMvpProxy;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mMvpProxy = createMvpProxy();
        mMvpProxy.createAndBindPresenter();
    }

    private FragmentMvpProxy createMvpProxy() {
        if (mMvpProxy == null) {
            mMvpProxy = new FragmentMvpProxyImpl<>(this);
        }
        return mMvpProxy;
    }

    @Override
    protected void unbindView(View view) {
        super.unbindView(view);
        mMvpProxy.unbindPresenter();

    }

    //***************************************IBaseView方法实现-START*************************************
    @Override
    public Context getContext() {
        return super.getContext();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void dismissLoading() {

    }

    @Override
    public void onEmpty(String emptyData) {

    }

    @Override
    public void onError(int errorCode, String errorMsg) {

    }
    //***************************************IBaseView方法实现-END*************************************

}
